<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .form-group {
            margin-bottom: 15px;
        }
    </style>
</head>
<body>
    <div class="container mt-5">
        <h2>注册</h2>
        <form action="/user/add" method="post">
            <div class="form-group">
                <label for="username" class="form-label">用户名</label>
                <input type="text" class="form-control" id="username" name="username" style="width:200px" required>
            </div>
{#            <div class="form-group">#}
{#                <label for="email" class="form-label">邮箱</label>#}
{#                <input type="email" class="form-control" id="email" name="email" style="width:200px" required>#}
{#            </div>#}
            <div class="form-group">
                <label for="password" class="form-label">密码</label>
                <input type="password" class="form-control" id="password" name="password" style="width:200px" required>
            </div>
{#            <div class="form-group">#}
{#                <label for="verificationCode" class="form-label">验证码</label>#}
{#                <input type="text" class="form-control" id="verificationCode" name="verificationCode" style="width:100px" required>#}
{#                <#}
{#            </div>#}
            <button type="submit" class="btn btn-primary">注册</button>
        </form>
        <p class="mt-3">已有账号？<a href="/">登录</a></p>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!--    <script>-->
<!--        function sendVerificationCode() {-->
<!--            const email = document.getElementById('email').value;-->
<!--            if (!email) {-->
<!--                alert('请输入邮箱');-->
<!--                return;-->
<!--            }-->

<!--            // 发送验证码的请求-->
<!--            fetch('/send_verification_code', {-->
<!--                method: 'POST',-->
<!--                headers: {-->
<!--                    'Content-Type': 'application/json'-->
<!--                },-->
<!--                body: JSON.stringify({ email: email })-->
<!--            })-->
<!--            .then(response => response.json())-->
<!--            .then(data => {-->
<!--                if (data.success) {-->
<!--                    alert('验证码已发送，请查收邮件');-->
<!--                } else {-->
<!--                    alert('验证码发送失败，请稍后再试');-->
<!--                }-->
<!--            })-->
<!--            .catch(error => {-->
<!--                console.error('Error:', error);-->
<!--                alert('验证码发送失败，请稍后再试');-->
<!--            });-->
<!--        }-->

<!--        function validateForm() {-->
<!--            const verificationCode = document.getElementById('verificationCode').value;-->
<!--            if (!verificationCode) {-->
<!--                alert('请输入验证码');-->
<!--                return false;-->
<!--            }-->

<!--            // 验证验证码的请求-->
<!--            fetch('/verify_code', {-->
<!--                method: 'POST',-->
<!--                headers: {-->
<!--                    'Content-Type': 'application/json'-->
<!--                },-->
<!--                body: JSON.stringify({ code: verificationCode })-->
<!--            })-->
<!--            .then(response => response.json())-->
<!--            .then(data => {-->
<!--                if (data.success) {-->
<!--                    document.getElementById('registerForm').submit();-->
<!--                } else {-->
<!--                    alert('验证码错误，请重新输入');-->
<!--                }-->
<!--            })-->
<!--            .catch(error => {-->
<!--                console.error('Error:', error);-->
<!--                alert('验证码验证失败，请稍后再试');-->
<!--            });-->

<!--            return false; // 阻止表单默认提交-->
<!--        }-->
<!--    </script>-->
</body>
</html>
